<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../layui/css/layui.css">
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <form class="form-horizontal" onsubmit="return false" id="form">
        <fieldset>
            <div class="form-group">
                <label class="col-md-2 control-label">工资</label>
                <div class="col-md-10" style="width: 300px">
                    <select class="form-control input-sm" name="salaryId" id="salaryId"
                            data-bv-notempty="true" data-bv-notempty-message="工资不能为空">
                    </select>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>申诉理由</label>
                <div class='col-md-10'>
                    <textarea class='layui-textarea' type='text' id='reason' name="reason"
                           placeholder="请填写申诉理由" data-bv-notempty='true' data-bv-notempty-message='请填写申诉理由'></textarea>
                </div>
            </div>
            <div class="form-actions">
                <div class="row" align="center">
                    <div class="col-md-12">
                        <button class="btn btn-primary" onclick="location.href='appealList.html'">返回</button>
                        <button class="btn btn-primary" type="submit" onclick="add()">
                            <i class="fa fa-save"></i> 保存
                        </button>
                    </div>
                </div>
            </div>
        </fieldset>
    </form>
</div>
<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../js/jq.js"></script>
<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="../../js/bootstrap/bootstrap-select.min.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../js/my/roles/role.js"></script>
<script type="text/javascript" src="../../layui/layui.js"></script>
<script type="text/javascript" src="../../js/dict.js"></script>
<script type="text/javascript" src="../../js/my/queryData.js?v=2"></script>
<script type="text/javascript">
    layui.use(['layer'], function () {
        var layer = layui.layer;

        initAppeal("salaryId");
    });

    $('#form').bootstrapValidator();

    function initAppeal(id) {
        $.ajax({
            type: 'get',
            url: '/empSalary/mySalary',
            contentType: "application/json; charset=utf-8",
            success: function (response) {
                if (response.code == "2000") {
                    var select_ = $("#" + id);
                    for (var i = 0; i < response.data.length; i++) {
                        var item = response.data[i];
                        select_.append("<option value='" + item.id + "'>工资时间：" + item.wageTime + "，实际工资：" + item.actualSalary + "</option>")
                    }
                } else {
                    layer.alert(response.message, {icon: 2});
                }
            }
        });
    }

    function add() {
        var bootstrapValidator = $("#form").data('bootstrapValidator');
        bootstrapValidator.validate();
        if (!bootstrapValidator.isValid()) {
            return;
        }
        var formdata = $("#form").serializeObject();
        $.ajax({
            type: 'post',
            url: '/empAppeal',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(formdata),
            success: function (response) {
                layer.msg("操作成功", {shift: -1, time: 1000}, function () {
                    location.href = "appealList.html";
                });
            }
        });
    }
</script>
</body>
</html>